package com.cennavi.minenavidemo.activity.tts;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import com.cennavi.minenavidemo.R;
import com.minedata.minenavi.mapdal.TTSManager;
import com.minedata.minenavi.navi.NaviSpeaker;

/**
 * 语音播报
 */
public class TTSActivity extends AppCompatActivity {
    int volume = 10;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tts);

        initView();
    }

    private void initView() {
        findViewById(R.id.button1).setOnClickListener(view -> {
            float v = volume * 1.0f / 10;
            TTSManager.setPlayerVolume(v, v);
            NaviSpeaker.enqueue("语音播报，测试成功，欢迎使用，感谢支持");
        });
        findViewById(R.id.button2).setOnClickListener(v -> NaviSpeaker.stop());
        findViewById(R.id.button3).setOnClickListener(view -> {
            volume++;
            if (volume > 10) volume = 10;
            float v = volume * 1.0f / 10;
            TTSManager.setPlayerVolume(v, v);
        });
        findViewById(R.id.button4).setOnClickListener(view -> {
            volume--;
            if (volume < 0) volume = 0;
            float v = volume * 1.0f / 10;
            TTSManager.setPlayerVolume(v, v);
        });
    }

    @Override
    protected void onStart() {
        super.onStart();
    }

    @Override
    protected void onStop() {
        super.onStop();
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}
